<template>
  <el-dialog
    :visible.sync="dialogVisible"
    class="companyDetail"
    title="公司信息维护"
    width="30%"
    :close-on-click-modal="false"
    :before-close="handleClose"
  >
    <el-form ref="companyForm" :model="dataInfo" :rules="rules" label-width="6rem">
      <el-row :gutter="20">
        <el-col :span="12">
          <el-form-item label="公司代码:" prop="companyCode">
            <el-input v-model="dataInfo.companyCode" :disabled="disabled" placeholder="公司代码" />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="公司名称:" prop="name">
            <el-input v-model="dataInfo.name" :disabled="disabled" placeholder="公司名称" />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="12">
          <el-form-item label="联系人:" prop="contacts">
            <el-input v-model="dataInfo.contacts" :disabled="disabled" placeholder="联系人" />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="联系电话:" prop="tel">
            <el-input v-model="dataInfo.tel" :disabled="disabled" placeholder="联系电话" />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="24">
          <el-form-item label="公司地址:" prop="addr">
            <el-input v-model="dataInfo.addr" :disabled="disabled" placeholder="请输入公司地址" />
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button @click="dialogVisible = false">取 消</el-button>
      <el-button type="primary">确 定</el-button>
    </span>
  </el-dialog>
</template>

<script>
export default {
  props: {
    disabled: {
      type: Boolean,
      required: true
    },
    parentId: {
      type: String,
      required: false,
      default: ''
    }
  },
  data() {
    return {
      rules: {
        companyCode: [{
          required: true,
          message: '请填写公司代码',
          trigger: 'blur'
        }],
        name: [{
          required: true,
          message: '请填写公司名称',
          trigger: 'blur'
        }],
        contacts: [{
          required: true,
          message: '联系人不能为空',
          trigger: 'blur'
        }],
        tel: [{
          required: true,
          message: '联系电话不能为空',
          trigger: 'blur'
        }],
        addr: [{
          required: true,
          message: '公司地址不能为空',
          trigger: 'blur'
        }]
      },
      dataInfo: {},
      dialogVisible: false
    }
  },
  methods: {
    handleClose() {
      this.dialogVisible = false
    }
  }
}
</script>

<style lang="scss">
.companyDetail {}
</style>
